package com.chixing.day16_io;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class WriterDemo {
    public static void main(String[] args) {
        //1.创建字符写入流对象
        Writer w = null;
        try {
             w = new FileWriter("d://test1/hello1.txt",true); //append:true 追加  false:覆盖
        } catch (IOException e) {
            e.printStackTrace();
        }
        //写入数据
        String txt = "Creates a file output stream to write to the file with the specified name. If the second argument is true";
        try {
            w.write(txt);
            w.flush();  //刷新缓冲区
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

